<template>
  <div>
    <div class="tl-form-line-title">
      结果分析
    </div>
    <!--表格渲染-->
    <el-table class="tl-table" ref="mainTable" :height="200" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
      <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
      <el-table-column prop="bidpackagenumber" label="包号" width="200px" sortable="custom" sort-by="bidpackagenumber" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="dispbidresult" label="中标结果" width="150px" sortable="custom" sort-by="bidresult" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="bulletintime" label="中标结果公告时间" width="150px" sortable="custom" sort-by="bulletintime" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="disppartake" label="是否可参与" width="100px" sortable="custom" sort-by="partake" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="bidmanufactor" label="中标厂家" min-width="200px" sortable="custom" sort-by="bidmanufactor" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="bidwinfund" label="中标金额（万元）" width="150px" sortable="custom" sort-by="bidwinfund" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
    </el-table>
    <tl-edit ref="editForm" :reviewModel="model" @refresh="doRefresh"></tl-edit>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './editnew'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
import { validateNull } from '@tapui/utils/validate'
export default {
  name: 'mpmProjectWinBidInfo',
  mixins: [mixin_list],
  components: { tlEdit },
  data() {
    return {
      description: '中标信息表-列表查询',
      urlPrefix: '/mpm/projectWinBidInfo/',
      url: {
        // queryCodeList: '/mpm/projectWinBidInfo/dataCodeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'createon',
        sord: 'asc'
      },
      pageInfo: {
        currentPage: 1, // 当前页面
        pageSize: 1000, // 每页记录数
        pageSizes: ['10', '50', '100'],
        totalCount: 0 // 总数
      },
      isQueryOnCreated: false
    }
  },
  props: {
    disableSave: {
      default: false,
      type: Boolean
    },
    model: {
      default: function() {
        return {}
      },
      type: Object
    }
  },
  methods: {
    beforeLoadData() {
      if (!this.model.id) {
        return false
      }
      this.queryParam.qry_projectcode = this.model.projectcode
      this.queryParam.qry_reviewid = this.model.id
      return true
    },
    afterLoadData() {
      this.$emit('setWinBidInfo')
    },
    doRowDbClick(row, column, event) {
        if (row.autoflag === 1) {
            this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
        } else if (this.model.state === 0 || this.model.state === 2) {
            this.openEditDialog('editForm', row[this.$refs.mainTable.rowKey])
        } else {
            this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
        }
    },
    /** 列表数据加载开始 */
    async loadData(paramMap) {
      if (!this.url.list) {
        this.$tap.alert('请设置list地址!', 'warning')
        return
      }
      // 得到加载分页
      if (validateNull(paramMap) === false && Object.keys(paramMap).indexOf('currentPage') > -1) {
        this.pageInfo.currentPage = paramMap['currentPage']
      }
      if (!this.beforeLoadData()) return
      // 查询条件
      var params = this.getQueryParams()
      // 数据查询
      this.loading = true
      return await getAction(this.url.list, params)
        .then((res) => {
          if (res.success) {
            this.datas = res.result.dataList
            this.pageInfo.totalCount = res.result.totalCount
            // 初始化自定义列
            if (typeof this.$refs.toolbar !== 'undefined') {
              this.$refs.toolbar.doInitTableColumn()
            }
          } else {
            this.$tap.alert(res.message, 'warning')
          }
          this.afterLoadData()
          this.loading = false
          return true
        })
        .catch((err) => {
          this.loading = false
          return false
        })
    }
  }
}
</script>

<style scoped></style>
